package com.tudouji.project.bill.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.bill.domain.Sellitem;
import com.tudouji.project.bill.service.ISellitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 订单明细Controller
 * 
 * @author tudouji
 * @date 2021-01-14
 */
@RestController
@RequestMapping("/bill/sellitem")
public class SellitemController extends BaseController
{
    @Autowired
    private ISellitemService sellitemService;

    /**
     * 查询订单明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(Sellitem sellitem)
    {
        startPage();
        List<Sellitem> list = sellitemService.selectSellitemList(sellitem);
        return getDataTable(list);
    }

    /**
     * 导出订单明细列表
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:export')")
    @Log(title = "订单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Sellitem sellitem)
    {
        List<Sellitem> list = sellitemService.selectSellitemList(sellitem);
        ExcelUtil<Sellitem> util = new ExcelUtil<Sellitem>(Sellitem.class);
        return util.exportExcel(list, "sellitem");
    }

    /**
     * 获取订单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(sellitemService.selectSellitemById(guid));
    }

    /**
     * 新增订单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:add')")
    @Log(title = "订单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Sellitem sellitem)
    {
        return toAjax(sellitemService.insertSellitem(sellitem));
    }

    /**
     * 修改订单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:edit')")
    @Log(title = "订单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Sellitem sellitem)
    {
        return toAjax(sellitemService.updateSellitem(sellitem));
    }

    /**
     * 删除订单明细
     */
    @PreAuthorize("@ss.hasPermi('bill:sellitem:remove')")
    @Log(title = "订单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(sellitemService.deleteSellitemByIds(guids));
    }
}
